package mapping

import (
	"time"

	"gitee.com/dayu1985/framework/utils"
)

//Bean 对象
type Bean struct {

	/////////////////////////

	//ID
	ID *string `bson:"_id,omitempty" json:"_id,omitempty" form:"_id"`

	//权值
	Weight *int `bson:"weight,omitempty" json:"weight,omitempty" form:"weight"`

	//状态
	Status *int `bson:"status,omitempty" json:"status,omitempty" form:"status"`

	//创建时间
	Created *int64 `bson:"created,omitempty" json:"created,omitempty" form:"created"`

	//更新时间
	Changed *int64 `bson:"changed,omitempty" json:"changed,omitempty" form:"changed"`
}

//NewBean 新对象
func (bean *Bean) NewBean(ID string) {

	bean.ID = &ID

	bean.Status = utils.PtrOfInt(1)
	bean.Created = utils.PtrOfInt64(time.Now().Unix())
	bean.Changed = utils.PtrOfInt64(time.Now().Unix())
}

//UpdateBean 更新对象
func (bean *Bean) UpdateBean(ID string) {

	bean.ID = &ID
	bean.Changed = utils.PtrOfInt64(time.Now().Unix())
}
